package com.kkd.kkdapp.adapter;

import java.text.DecimalFormat;
import java.util.List;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.kkd.kkdapp.R;
import com.kkd.kkdapp.base.MyBaseAdapter;
import com.kkd.kkdapp.http.entity.EvetyDayJoinRecordDatalist;
import com.nostra13.universalimageloader.core.ImageLoader;

public class EvetyDayJoinRecordAdapter extends
		MyBaseAdapter<EvetyDayJoinRecordDatalist> {
	private DecimalFormat df;

	public EvetyDayJoinRecordAdapter(Context context) {
		super(context);
	}

	@Override
	public View getMyView(int position, View convertView, ViewGroup parent) {
		ViewHodler viewhodler;
		if (convertView == null) {
			convertView = View.inflate(context,
					R.layout.condition_listview_item2, null);
			viewhodler = new ViewHodler();
			viewhodler.phone = (TextView) convertView.findViewById(R.id.phone);
			viewhodler.date = (TextView) convertView.findViewById(R.id.date);
			viewhodler.count = (TextView) convertView.findViewById(R.id.count);
			viewhodler.iv_head = (ImageView) convertView
					.findViewById(R.id.iv_head);
			df = new DecimalFormat("0.00");
			convertView.setTag(viewhodler);
		} else {
			viewhodler = (ViewHodler) convertView.getTag();
		}
		List<EvetyDayJoinRecordDatalist> poilist = this.getAdapterData();
		viewhodler.phone.setText(poilist.get(position).getCustomerName());
		String count = df
				.format((double) poilist.get(position).getAmount() / 100);
		viewhodler.count.setText(count + "元");
		viewhodler.date.setText(poilist.get(position).getCreateTime());
		ImageLoader.getInstance().displayImage(
				poilist.get(position).getImageUrl(), viewhodler.iv_head,
				R.drawable.myrecommendfriend_head);
		return convertView;
	}

	static class ViewHodler {
		TextView phone;
		TextView date;
		TextView count;
		ImageView iv_head;
	}
}
